import React from 'react'
// ===================================================================== Temp
import FormModal from '#cpt/temp/FormModal'
// ===================================================================== global declare
const { $fn, $Lazy } = window
// ===================================================================== Lazy
const $cache 	= $Lazy.file(()=>import('#private/cache-api'))
// ===================================================================== component
class Index extends React.Component{
	state = {
		data:[],
		pag: {},
		selectedKeys:[],
		//修改账期
		formData:[
			{ label: '条码号',			name: 'old_spec_code', disabled:true },
			{ label: '当前账期',			name: 'phase_str', disabled:true },
			{ label: '修改后账期',		name: 'phase_id', type: 'select', 	loading:true, required:true },
		]
	}
	
	model = {}
	
	open = (rows,data) => {
		const { uuid } = rows[0]
		this.modal.open({ formRef:this.formRef })
		this.submit = { uuid }
		this.getSelect(data,rows[0])
	}

	// 获取下拉数据
	getSelect = (data,rows) => {
		const { formData } = this.state
		$cache.then( async f => {
			// 账期
			$fn.setRow(formData, 'phase_id', data ) 
			this.setState({ formData })
			this.formRef.setValue(rows)
		})
	}
	
	render(){
		return FormModal.call(this,{ title:'修改账期', api: 'bill/changephase' })
	}
}

export default Index